<?php
/**
 * 版本:酷享云支付3.0版
 * 作者：余生
 * 官网：www.kuxiangcms.com
 * 技术QQ：2316803263
 * 酷享云支付官网:pay.kuxiangcms.cn
**/
//订单列表
include("../includes/common.php");
include './head.php';
if($islogin==1){}else exit("<script language='javascript'>window.location.href='./login.php';</script>");
?> 
<div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a>
                    <cite>商户订单列表</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
            </a>
        </div> 
         <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                       <div class="layui-card-body ">
<?php
$my=isset($_GET['my'])?$_GET['my']:null;
echo ' <form class="layui-form layui-col-space5" action="order.php" method="GET">
        <input type="hidden" name="my" value="search">
                              
                                <div class="layui-input-inline layui-show-xs-block">
                                    <select name="column" class="form-control">
                                    <option value="trade_no">订单号</option>
                                    <option value="out_trade_no">商户订单号</option>
                                    <option value="pid">商户号</option>
                                    <option value="name">商品名称</option>
                                    <option value="money">金额</option>
                                    </select>
                                </div>
                              
                                <div class="layui-input-inline layui-show-xs-block">
                                    <input type="text" name="value" placeholder="搜索内容" autocomplete="off" class="layui-input"></div>
                                <div class="layui-input-inline layui-show-xs-block">
                                    <button class="layui-btn"  type="submit" lay-filter="sreach">
                                        <i class="layui-icon">&#xe615;</i></button>
                                </div>
                            </form>
';

if($my=='search') {
	if($_GET['column']=='name'){
		$sql=" `{$_GET['column']}` like '%{$_GET['value']}%'";
	}else{
		$sql=" `{$_GET['column']}`='{$_GET['value']}'";
	}
	$numrows=$DB->query("SELECT count(*) from pay_order WHERE{$sql}")->fetchColumn();
	$con='包含 '.$_GET['value'].' 的共有 <b>'.$numrows.'</b> 条订单';
	$link='&my=search&column='.$_GET['column'].'&value='.$_GET['value'];
}else{
	$numrows=$DB->query("SELECT count(*) from pay_order WHERE 1")->fetchColumn();
	$sql=" 1";
	$con='共有 <b>'.$numrows.'</b> 条订单';
}
echo $con;
?>

  <div class="layui-card-body ">
                            <table class="layui-table layui-form">
                                <thead>
                                    <tr> 
                                        <th>订单号/商户订单号</th>
                                        <th>商户号/网站域名</th>
                                        <th>商品名称/金额</th>
                                        <th>通道名称</th>
                                        <th>创建时间/完成时间</th>
                                        <th>支付状态</th>
										<th>操作</th>
                                </thead>
                                <tbody>
<?php                          
$pagesize=30;
$pages=intval($numrows/$pagesize);
if ($numrows%$pagesize)
{
 $pages++;
 }
if (isset($_GET['page'])){
$page=intval($_GET['page']);
}
else{
$page=1;
}
$offset=$pagesize*($page - 1);

$rs=$DB->query("SELECT * FROM pay_order WHERE{$sql} order by trade_no desc limit $offset,$pagesize");
while($res = $rs->fetch())
{
	$url=creat_callback($res);
	$domain=!empty($res['domain'])?$res['domain']:getdomain($res['notify_url']);
echo '

        
        <tr><td><b>'.$res['trade_no'].'</a></b><br/>'.$res['out_trade_no'].'</td>
       <td>'.$res['pid'].'<br/>'.getdomain($res['notify_url']).'</td>
       <td>'.$res['name'].'<br/>￥'.$res['money'].'</td>
       <td>'.$res['type'].'</td>
       <td>'.$res['addtime'].'<br/>'.$res['endtime'].'</td>
       <td>'.($res['status']==1?'<font color=green>已完成</font>':'<font color=blue>未完成</font>').'</td> 
       <td>'.($res['status']==1?'<a href="' .$url['notify'].'" title="支付通知" target="_blank" rel="noreferrer" class="layui-btn layui-btn-sm layui-btn-normal">补单<a/>':'<a class="layui-btn layui-btn-sm layui-btn-danger">禁止补单</a>').'</td></tr>                              
';
}
?>
          </tbody>
        </table>
      </div>

        <div class="layui-card-body ">
                            <div class="page">
                                <div>

<?php
echo'<ul class="pagination">';
$first=1;
$prev=$page-1;
$next=$page+1;
$last=$pages;
if ($page>1)
{
echo '<li><a href="order.php?page='.$first.$link.'">首页</a>';
echo '<li><a href="order.php?page='.$prev.$link.'">&laquo;</a></li>';
} else {
echo '<li class="disabled"><a>首页</a></li>';
echo '<li class="disabled"><a>&laquo;</a></li>';
}
for ($i=1;$i<$page;$i++)
echo '<li><a href="order.php?page='.$i.$link.'">'.$i .'</a></li>';
echo '<li class="disabled"><a>'.$page.'</a></li>';
if($pages>=10)$s=10;
else $s=$pages;
for ($i=$page+1;$i<=$s;$i++)
echo '<li><a href="order.php?page='.$i.$link.'">'.$i .'</a></li>';
echo '';
if ($page<$pages)
{
echo '<li><a href="order.php?page='.$next.$link.'">&raquo;</a></li>';
echo '<li><a href="order.php?page='.$last.$link.'">尾页</a></li>';
} else {
echo '<li class="disabled"><a>&raquo;</a></li>';
echo '<li class="disabled"><a>尾页</a></li>';
}
echo'</ul>';
#分页
?>

 <!--请勿盗卖酷享云支付源码程序 ，如发现盗卖将不提供更新服务，系统由余生网络信息提供技术服务-->
                                    
                                    
                                   </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

  <script>layui.use(['laydate', 'form'],
        function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#start' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#end' //指定元素
            });
        });
      </script>